package arquivo;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.io.File;
import java.util.ArrayList;

import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class TesteLeitor extends JFrame {
	
	public TesteLeitor() {
		super("Teste do leitor");
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(800, 600);
		setVisible(true);
		
		Painel panel = new Painel();
		File entrada = new File("c:\\txtsAlgoritmos\\percursoEmLargura.txt");
		ArrayList<JLabel> labels = LeitorArquivo.ler(entrada);
		panel.setVisible(true);
		for(JLabel label : labels){
			panel.add(label);
		}
		Painel numeros = new Painel();
		for(int i = 1; i <= labels.size(); ++i){
			numeros.add(new JLabel("  "+i+":   "));
		}
		getContentPane().add(BorderLayout.WEST, numeros);
		getContentPane().add(BorderLayout.CENTER, panel);
		repaint();
	}	
	
	public void go(){};
	
	public static void main(String[] args){
		
		TesteLeitor teste = new TesteLeitor();
		teste.go();
		/*
		File entrada = new File("c:\\txtsAlgoritmos\\dijkstra.txt");
		ArrayList<JLabel> labels = LeitorArquivo.ler(entrada);
		System.out.println(labels);
		*/
	}
	
	
	
	public class Painel extends JPanel {

		public void paintComponent (Graphics g) {
			super.paintComponent(g) ;
			g.setColor(Color.WHITE) ;
			g.fillRect(0,0,this.getWidth(),this.getHeight()) ;
		}

		
		public Painel() {
			super() ;
			this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)) ;
		}
		
	}
	
}
